package com.photoeditor.demo.ui.widget.share;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.photoeditor.R;
import com.photoeditor.demo.util.FontUtil;


/**
 * 这个是分享界面GridView的小的单个ITEM
 */
public class ShareImageLittleItem extends RelativeLayout {
    private ShareImageItem.ShareImageItemData mItemData;
    private ImageView mIcon;
    private TextView mLabel;

    public ShareImageLittleItem(Context context) {
        super(context);
        initView();
    }

    public ShareImageLittleItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    public ShareImageLittleItem(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initView();
    }

    private void initView() {
        LayoutInflater.from(getContext()).inflate(R.layout.item_share_image_little, this, true);
        mIcon = (ImageView) findViewById(R.id.share_icon);
        mLabel = (TextView) findViewById(R.id.share_label);
        FontUtil.setCustomFont(mLabel);
    }

    public ShareImageItem.ShareImageItemData getItemData() {
        return mItemData;
    }

    /**
     * @param item 数据体
     */
    public void setItemData(ShareImageItem.ShareImageItemData item) {
        this.mItemData = item;
    }

    /**
     * 用于ArrayAdapter中getView的缓存
     */
    public static class ViewHolder {
        ImageView icon;
        TextView label;
    }

    public ImageView getmIcon() {
        return mIcon;
    }

    public TextView getmLabel() {
        return mLabel;
    }
}
